﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include "result.h"
#include <QtDebug>
#pragma execution_character_set("utf-8")

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setWindowTitle("图片选择页面");
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_open1_clicked()
{
    QString fileName = QFileDialog::getOpenFileName(this,
                                             "选择图片",
                                             "/",
                                             "图片文件(*.jpg *.png *.bmp);"
                                             ";"
                                             "All(*.*)");
    oldImg1=new QPixmap(fileName);

    oldImgPath1=fileName;
    ui->old1->setScaledContents(true);
    oldImg1->scaled(ui->old1->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
    ui->old1->setPixmap(*oldImg1);

}

void MainWindow::on_open2_clicked()
{
    QString fileName = QFileDialog::getOpenFileName(this,
                                             "选择图片",
                                             "/",
                                             "图片文件(*.jpg *.png *.bmp);"
                                             ";"
                                             "All(*.*)");
    oldImg2=new QPixmap(fileName);
    oldImgPath2=fileName;
    ui->old2->setScaledContents(true);
    oldImg2->scaled(ui->old2->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
    ui->old2->setPixmap(*oldImg2);
}

void MainWindow::on_start_clicked()
{
    result *resultimg=new result();
    qDebug()<<oldImgPath1<<endl;
    resultimg->qold1=oldImgPath1;
    resultimg->qold2=oldImgPath2;
    resultimg->check();
    resultimg->show();
}
